
$(function() {
	
	$($("input[id^='exten']:visible")).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: 'emp.php?do=Exten.ajax',
				dataType: "json",
				data: {
					featureClass: "P",
					style: "full",
					maxRows: 12,
					q: request.term
				},
				success: function( data ) {
					response( $.map( data, function( item ) {
						return {
							label: item.exten + " [" + item.name + ", " + item.dept_t + "]",
							value: item.exten + ":" + item.name
						}
					}));
				}
			});
		},
		
		minLength: 1
	});
	
	$("input[id^='zone']:visible").autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: 'info.php?do=Zone.ajax_zjm2',
				dataType: "json",
				data: {
					featureClass: "P",
					style: "full",
					maxRows: 12,
					q: request.term
				},
				success: function( data ) {
					response( $.map( data, function( item ) {
						return {
							zone: item.zone,
							label: item.zjm + " [" + item.city + ", " + item.zone + "]",
							value: item.zone + ":" + item.city
						}
					}));
				}
			});
		},
		
		select: function( event, ui ) {
			$("input[id^='zone']:visible").val(ui.item.zone);
		},
		
		minLength: 1
	});

	$('textarea').css("width", 300);
});
